package com.leon.androidcoursedesign.utils.dataBaseUtils;

import android.content.Context;

public class SQLiteHelperFactory {
    private final Context context;
    private final Tables table;

    public SQLiteHelperFactory(Context context, Tables table) {
        this.context = context;
        this.table = table;
    }

    /**
     * 根据table获取对应的对象
     *
     * @return  返回对应数据库所使用的工具类
     */
    public SQLiteHelper getInstance() {
        SQLiteHelper sqLiteHelper;

        switch (table) {
            case AccountInfo:
                sqLiteHelper = new AccountInfoUtils(context);
                break;
            case Course:
                sqLiteHelper = new CourseUtils(context);
                break;
            case Note:
                sqLiteHelper = new NoteUtils(context);
                break;
            default:
                sqLiteHelper = new SQLiteHelper(context, 1);
                break;
        }

        return sqLiteHelper;
    }
}
